package com.whfc.ms.api.emp.service.impl;

import com.whfc.common.result.PageData;
import com.whfc.emp.dto.AppEmpConfessDTO;
import com.whfc.emp.dto.AppEmpDTO;
import com.whfc.emp.param.AppEmpConfessAddParam;
import com.whfc.emp.param.AppEmpConfessEditParam;
import com.whfc.emp.service.AppEmpConfessService;
import com.whfc.emp.service.AppEmpService;
import com.whfc.fuum.entity.SysEmpUser;
import com.whfc.fuum.service.SysUserService;
import com.whfc.ms.api.emp.service.MsAppEmpConfessService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-09-02 16:32
 */
@Service
public class MsAppEmpConfessServiceImpl implements MsAppEmpConfessService {

    @DubboReference(interfaceClass = AppEmpConfessService.class, version = "1.0.0")
    private AppEmpConfessService appEmpConfessService;

    @DubboReference(interfaceClass = AppEmpService.class, version = "1.0.0")
    private AppEmpService appEmpService;

    @DubboReference(interfaceClass = SysUserService.class, version = "1.0.0")
    private SysUserService sysUserService;

    @Override
    public PageData<AppEmpConfessDTO> list(Integer empId, Integer pageNum, Integer pageSize) {
        return appEmpConfessService.list(empId, pageNum, pageSize);
    }

    @Override
    public void add(AppEmpConfessAddParam param) {
        appEmpConfessService.add(param);
    }

    @Override
    public void edit(AppEmpConfessEditParam param) {
        appEmpConfessService.edit(param);
    }

    @Override
    public void del(Integer confessId) {
        appEmpConfessService.del(confessId);
    }

    @Override
    public List<AppEmpDTO> getUserList(Integer deptId, String keyword) {
        List<AppEmpDTO> pageData = appEmpService.list(deptId, keyword);
        for (AppEmpDTO appEmpDTO : pageData) {
            SysEmpUser empUser = sysUserService.getEmpUserByEmpId(appEmpDTO.getEmpId());
            appEmpDTO.setHasSysUserInfo(empUser != null);
        }
        return pageData;
    }
}
